package com.mes.defece.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mes.common.pojo.MESResult;
import com.mes.defece.mapper.TaskMapper;
import com.mes.defece.service.TaskService;
import com.mes.pojo.defece.Tasks;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author 侯伟豪
 * @Company 起点编程
 * @Description
 * @Time 2024/10/25 15:17
 */
@Service
public class TaskServiceImpl implements TaskService {
    @Autowired
    private TaskMapper taskMapper;

    @Override
    public MESResult selectAll(Tasks tasks, Integer page, Integer limit) {
        PageHelper.startPage(page, limit);
        List<Tasks> task = taskMapper.selectAll(tasks);
        return MESResult.success(new PageInfo<>(task));
    }

    @Override
    public MESResult selectById(String taskId) {
        return MESResult.success(taskMapper.selectById(taskId));
    }

    @Override
    public MESResult deleteTask(String taskId) {
        Tasks tasks = new Tasks();
        tasks.setTaskId(taskId);
        tasks.setTaskStatus(99);
        return MESResult.success(taskMapper.deleteTaskById(tasks));
    }
}